﻿using BielskoNoca.DAL.Abstract;
using BielskoNoca.DAL.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Web;

namespace BielskoNoca.DAL.Concrete
{
    public class RunnerRepository: IRunnerRepository
    {
        private BielskoNocaDataEntities context;
            //= new BielskoNocaDataEntities();

        public RunnerRepository(BielskoNocaDataEntities context)
        {
            this.context = context;
        }

        public int Add(Runner runner)
        {
            Runner tEntity = this.context.Runners.Add(runner);
            context.SaveChanges();

            return tEntity.Id;
        }

        public System.Linq.IQueryable<Runner> Query
        {
            get { return this.context.Runners; }
        }

        public Runner GetFirstOrDefault(System.Linq.Expressions.Expression<System.Func<Runner, bool>> whereCondition)
        {
            throw new System.NotImplementedException();
        }

        public void Delete(Runner entity)
        {
            throw new System.NotImplementedException();
        }

        public void Attach(Runner entity)
        {
            throw new System.NotImplementedException();
        }

        public System.Collections.Generic.IList<Runner> GetAll(System.Linq.Expressions.Expression<System.Func<Runner, bool>> whereCondition)
        {
            throw new System.NotImplementedException();
        }

        public System.Collections.Generic.IList<Runner> GetAll()
        {
            return this.Query.ToList();
        }

        public long Count(System.Linq.Expressions.Expression<System.Func<Runner, bool>> whereCondition)
        {
            throw new System.NotImplementedException();
        }

        public long Count()
        {
            throw new System.NotImplementedException();
        }

        public bool Any(Expression<Func<Runner, bool>> condition)
        {
            return this.Query.Any(condition);
        }

        public Runner GetById(int id)
        {
            return this.Query.FirstOrDefault(run => run.Id == id);
        }
    }
}